package com.acme.bankapp.service.bank;

import com.acme.bankapp.domain.bank.Bank;
import com.acme.bankapp.domain.bank.CheckingAccount;
import com.acme.bankapp.domain.bank.Client;
import com.acme.bankapp.domain.bank.SavingAccount;

/**
 * Created by Student on 18.08.2014.
 */
public class BankApplication {

    public static void main(String[] args) {
        Bank bank = new Bank();

        BankService.addClient(bank, new Client(new SavingAccount(10)));
        BankService.addClient(bank, new Client(new SavingAccount(10)));
        BankService.addClient(bank, new Client(new CheckingAccount(20, 50)));
        BankService.addClient(bank, new Client(new CheckingAccount(10)));
        modifyBank(bank);
        printBalance(bank);
        BankService.printMaximumAmountToWithdraw(bank);

    }


    private static void modifyBank(Bank bank) {
        BankService.getClients(bank).get(0).getAccounts().deposit(10);
        BankService.getClients(bank).get(2).getAccounts().withdraw(30);
    }

    private static void printBalance(Bank bank) {
        System.out.println("Accounts' balance");
        for (Client client : BankService.getClients(bank)) {
            System.out.println(client.getAccounts().getBalance());
        }
    }
}
